<template>
  <div>
    <el-card>
      <el-table :data="rightslist" border style="width: 100%" height="78vh" stripe>
        <el-table-column type="index"> </el-table-column>
        <el-table-column prop="authName" label="权限名称"> </el-table-column>
        <el-table-column prop="path" label="路径"> </el-table-column>
        <el-table-column prop="level" label="权限等级">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.level == '0'"> 一级 </el-tag>
            <el-tag v-if="scope.row.level == '1'" type="success"> 二级 </el-tag>
            <el-tag v-if="scope.row.level == '2'" type="warning"> 三级 </el-tag>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
import { mapState, mapMutations } from 'vuex'
import { getrightslist } from '@/api'
export default {
  methods: {
    ...mapMutations(['getrightslist']),
    async getlist() {
      const { data: res } = await getrightslist('list')
      if (res.meta.status === 200) {
        this.getrightslist(res.data)
      } else {
        this.$message.error('获取权限列表失败')
      }
      console.log(res)
    }
  },
  created() {
    this.getlist()
  },
  computed: {
    ...mapState({
      rightslist: state => state.Rights.rightslist
    })
  }
}
</script>

<style></style>
